var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  a = require("../../../utils/http"),
  e = t(require("../../../utils/util")),
  n = new a.HTTP;
  let {updateName,qyinfo}=require("../../../api/attract/select")
Page({
  data: {
    xiangmu: [],
    ruzhu: [{
      id: 1,
      text: "实体"
    }, {
      id: 2,
      text: "挂靠"
    }],
    ruzhuleixing: 1,
    ruzhutext: "实体",
    zhuti: [{
      id: 1,
      text: "我方代办"
    }, {
      id: 2,
      text: "企业自办"
    }],
    zhutitype: 1,
    zhutitext: "企业自办",
    seletitle: [{
      id: 1,
      text: "人才招商"
    }, {
      id: 2,
      text: "高企招商"
    }, {
      id: 3,
      text: "区域招商"
    }]
  },
  selectEvent: function (t) {
    this.setData({
      ruzhuleixing: t.detail.selectedID,
      ruzhutext: t.detail.nowText
    })
  },
  selectEvents: function (t) {
    this.setData({
      zhutitype: t.detail.selectedID,
      zhutitext: t.detail.nowText
    })
  },
  selectEvent4: function (t) {
    this.setData({
      kehutype: t.detail.selectedID,
      nowTextc: t.detail.nowText
    })
  },
  quxiao: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  handelItemChange: function (t) {
    var a = t.detail.value;
    this.setData({
      checkedList: a
    })
  },
  formSubmit: function (t) {
    console.log(this.data.length)
    var a = t.detail.value,
      e = this;
      console.log(a.qymc)
    wx.showModal({
      title: "提示",
      content: "请核对数据是否确定修改",
      success: function (t) {
        t.confirm ? "" == a.mianji || "" == a.dizhi || null == e.data.nowTextc ? wx.showToast({
          title: "请检查是否有必填项未填",
          icon: "none",
          duration: 1e3
        }) : e.data.length > 1 ? 
        n.request({
          url: "https://www.qlsyyun.com:3000/Removal/qybzfp",
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          method: "POST",
          data: {
            sfgk: e.data.ruzhutext,
            bllb: e.data.zhutitext,
            bid: e.data.name.bID,
            bm: e.data.name.bm,
            zsy: e.data.name.zsy,
            qymc: a.qymc,
            khbh: e.data.name.khbh,
            zt: e.data.name.bm,
            address: a.dizhi,
            tname: e.data.tname,
            khfj: e.data.name.khfj,
            yjss: e.data.name.yjss
          }
        }).then((function (t) {
          updateName({qymc:a.qymc,bid:e.data.name.bID}),
          n.request({
              url: "https://www.qlsyyun.com:3000/Removal/qyinfo",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                sfgk: e.data.ruzhutext,
                bllb: e.data.zhutitext,
                bid: e.data.name.bID,
                bm: e.data.name.bm,
                zsy: e.data.name.zsy,
                qymc: a.qymc,
                khbh: e.data.name.khbh,
                zt: e.data.name.bm,
                hyfl: e.data.name.sshy,
                khfj: e.data.name.khfj,
                yjss: e.data.name.yjss,
                zsgs: e.data.checkedList?e.data.checkedList:'',
                mj: a.mianji
              }
            }).then((function (t) {})),
            n.request({
              url: "https://www.qlsyyun.com:3000/Removal/zscb",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                bID: e.data.name.bID
              }
            }).then((function (t) {})),
            n.request({
              url: "https://www.qlsyyun.com:3000/Removal/zsjd",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                bm: e.data.name.bm,
                zsy: e.data.name.zsy,
                qymc: a.qymc,
                khbh: e.data.name.khbh,
                tname: e.data.tname
              }
            }).then((function (t) {})),
            n.request({
              url: "https://www.qlsyyun.com:3000/Removal/stjd",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                bm: e.data.name.bm,
                zsy: e.data.name.zsy,
                qymc: a.qymc,
                khbh: e.data.name.khbh,
                tname: e.data.tname,
                tjsj: e.data.tjsj,
                bID: e.data.name.bID
              }
            }).then((function (t) {})),
            n.request({
              url: "https://www.qlsyyun.com:3000/Removal/stmx",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                tjsj: e.data.tjsj,
                bm: e.data.name.bm,
                zsy: e.data.name.zsy,
                qymc: a.qymc,
                khbh: e.data.name.khbh,
                tname: e.data.tname,
                bID: e.data.name.bID
              }
            }).then((function (t) {})),
            wx.showToast({
              title: "提交成功",
              icon: "none",
              duration: 1e3,
              mask: !0,
              success: function () {
                setTimeout((function () {
                  var pages = getCurrentPages();
                  var beforePage = pages[pages.length - 2];
                  // 假设main()为页面A的数据方法，
                  beforePage.onLoad({ bID:e.data.name.bID, id: 1 });
                  wx.navigateBack({
                    delta: 1
                  })
                }), 1e3)
              }
            })
        })) : 
        (
          updateName({qymc:a.qymc,bid:e.data.name.bID}),
        //   n.request({
        //   url: "https://www.qlsyyun.com:3000/register/qyinfo",
        //   header: {
        //     "Content-Type": "application/x-www-form-urlencoded"
        //   },
        //   method: "POST",
        //   data: {
        //     sfgk: e.data.ruzhutext,
        //     bllb: e.data.zhutitext,
        //     bid: e.data.name.bID,
        //     bm: e.data.name.bm,
        //     zsy: e.data.name.zsy,
        //     qymc: a.qymc,
        //     khbh: e.data.name.khbh,
        //     zt: e.data.name.bm,
        //     jname: e.data.tname,
        //     hyfl: e.data.name.sshy,
        //     khfj: e.data.name.khfj,
        //     yjss: e.data.name.yjss,
        //     zsgs: e.data.checkedList?e.data.checkedList:'',
        //     mj: a.mianji
        //   }
        // })
        qyinfo({
          sfgk: e.data.ruzhutext,
          bllb: e.data.zhutitext,
          bid: e.data.name.bID,
          bm: e.data.name.bm,
          zsy: e.data.name.zsy,
          qymc: a.qymc,
          khbh: e.data.name.khbh,
          zt: e.data.name.bm,
          jname: e.data.tname,
          hyfl: e.data.name.sshy,
          khfj: e.data.name.khfj,
          yjss: e.data.name.yjss,
          zsgs: e.data.checkedList?e.data.checkedList:'',
          mj: a.mianji
        }).then((function (t) {
          n.request({
            url: "https://www.qlsyyun.com:3000/register/qid"
          }).then((function (t) {
            var d = t.data[0];
            n.request({
                url: "https://www.qlsyyun.com:3000/register/qybzfp",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  sfgk: e.data.ruzhutext,
                  bllb: e.data.zhutitext,
                  bid: e.data.name.bID,
                  bm: e.data.name.bm,
                  zsy: e.data.name.zsy,
                  qymc: a.qymc,
                  khbh: e.data.name.khbh,
                  zt: e.data.name.bm,
                  address: a.dizhi,
                  tname: e.data.tname,
                  khfj: e.data.name.khfj,
                  yjss: e.data.name.yjss,
                  qid: d.qID
                }
              }).then((function (t) {})),
              n.request({
                url: "https://www.qlsyyun.com:3000/register/zscb",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  bID: e.data.name.bID
                }
              }).then((function (t) {})),
              n.request({
                url: "https://www.qlsyyun.com:3000/register/zsjd",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  bm: e.data.name.bm,
                  zsy: e.data.name.zsy,
                  qymc: a.qymc,
                  khbh: e.data.name.khbh,
                  tname: e.data.tname
                }
              }).then((function (t) {})),
              n.request({
                url: "https://www.qlsyyun.com:3000/register/stjd",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  bm: e.data.name.bm,
                  zsy: e.data.name.zsy,
                  qymc: a.qymc,
                  khbh: e.data.name.khbh,
                  tname: e.data.tname,
                  bID: e.data.name.bID
                }
              }).then((function (t) {})),
              n.request({
                url: "https://www.qlsyyun.com:3000/register/stmx",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  tjsj: e.data.tjsj,
                  bm: e.data.name.bm,
                  zsy: e.data.name.zsy,
                  qymc: a.qymc,
                  khbh: e.data.name.khbh,
                  tname: e.data.tname,
                  bID: e.data.name.bID
                }
              }).then((function (t) {}))
          }))
        })), wx.showToast({
          title: "提交成功",
          icon: "none",
          duration: 1e3,
          mask: !0,
          success: function () {
            var pages = getCurrentPages();
            var beforePage = pages[pages.length - 2];
            // 假设main()为页面A的数据方法，
            beforePage.onLoad({ bID:e.data.name.bID, id: 1 });
            wx.navigateBack({
              delta: 1
            })
          }
        })) : t.cancel && console.log("用户点击取消")
      }
    })
  },
  onLoad: function (t) {
    var a = Object.keys(t).length;
    console.log(a);
    a > 1 && wx.setNavigationBarTitle({
      title: "提报迁址办证"
    });
    var d = this,
      m = wx.getStorageSync("infor"),
      s = wx.getStorageSync("user"),
      i = e.default.formatnow(new Date);
    n.request({
        url: "https://www.qlsyyun.com:3000/enterproject"
      }).then((function (t) {
        d.setData({
          xiangmu: t.data
        })
      })),
      m.yjss=m.yjss?m.yjss:0
      d.setData({
        tname: s[0],
        tjsj: i,
        name: m,
        length: a
      })
  }
});